import 'package:basic_common/common_exports.dart';

class ResetPwdController extends GetxController {
  TextEditingController oldPwdController = TextEditingController();
  TextEditingController newPwdController = TextEditingController();
  TextEditingController confirmPwdController = TextEditingController();

  /// 修改密码
  void resetPwd() async {
    String oldPwd = oldPwdController.text;
    String newPwd = newPwdController.text;
    String confirmPwd = confirmPwdController.text;
    if (oldPwd.isEmpty || newPwd.isEmpty || confirmPwd.isEmpty) {
      ToastUtils.toast("输入内容不能为空");
      return;
    }
    if (newPwd != confirmPwd) {
      ToastUtils.toast("两次输入密码不一致，请重新输入");
      return;
    }
    HttpData res =
        await ApiService().resetPwd(data: {"oldPwd": oldPwd, "newPwd": newPwd});
    if (res.code == 1) {
      Get.back();
      ToastUtils.toast("修改成功");
    } else {
      ToastUtils.toast("修改失败");
    }
  }
}
